<?php $this->Hinc('header')?>
<link href="/Public/Home/public/goods.css" rel="stylesheet" type="text/css">
<div id="loadinfos">

    <div class="main-box">
        <div class="main-content">
            <div id="ur_here">
                <!--导航-->
                <a href="/index.php">首页</a>
                <code>&gt;</code>
                <a href="<?php $this->U('Index','lis&fid='.$goods['f_id'])?>">
                    <?php echo $goods['title']?>
                </a> <code>&gt;</code> <?php echo $goods['name']?>
            </div>


            <!--商品图片-->
            <div class="main-content-left">
                <div class="bd">
                    <ul style="position: relative; width: 600px; height: 605px;">
                        <?php $i=0;foreach($goods['img'] as $k=>$v){if($v){?>
                            <li class="img_lb" style="<?php if($i!=0){echo 'display:none;';}?>position: absolute; width: 600px; left: 0px; top: 0px;">
                                <a href="javascript:void(0);">
                                <img src="<?php echo $v?>">
                                </a>
                            </li>
                        <?php $i++;}}?>
                    </ul>
                </div>
                <a class="prev" href="javascript:void(0)" style="opacity: 0.248512; display: block;"></a>
            <script>
                $(function () {
                    var num=0;
                    $('.prev').click(function () {
                        $('.img_lb').hide();
                        $($('.img_lb')[num]).show();
                        num++;
                        if(num>=$('.img_lb').length){num=0;}
                    })
                })
            </script>
            </div>

            <div class="main-content-right">
                <h1><?php echo $goods['name']?></h1>

                <p class="goods-info-phone">
                    <?php echo $goods['msg']?>
                </p>

                <!--规格-->
                <div class="select-option" id="option-standard">
                    <h4>规格</h4>
                    <ul>
                        <ul>
                            <?php foreach($goods_g as $v){?>
                                <li class="guige" did="<?php echo $v['id']?>" data="<?php echo $v['gmoney']?>">
                                    <a href="javascript:void(0);"><?php echo $v['gname']?></a>
                                </li>
                            <?php }?>
                        </ul>
                    </ul>
                </div>


                <div class="select-num">
                    <h4>数量</h4>
                    <a id="DelNum" class="sl" data="jian" href="javascript:void(0)">-</a>
                    <input name="number" disabled type="text" id="number" value="1" size="3">
                    <a id="AddNum" class="sl" data="jia" href="javascript:void(0)">+</a>
                </div>

                <!--用户id-->
                <input type="hidden" id="mid" value="<?php echo $_SESSION['Home']['Member']['id']?>">
                <!--商品id-->
                <input type="hidden" id="gid" value="<?php echo $goods['id']?>">
                <!--商品基本价格-->
                <input type="hidden" id="money" value="<?php echo $goods['money']?>">
                <!--商品库存-->
                <input type="hidden" id="kc" value="<?php echo $goods['kc']?>">

                <div class="select-buy">
                    <p class="select-buy-price" data-price="￥1099.00" data-makeprice="0">
                        <span>￥ <b id="zmoney"><?php echo $goods['money']?></b></span>
                    </p>

                    <a class="buy-btn">加入购物车</a>

                    <a class="love-btn" <?php if($mlike>0){echo "style='color:red'";}?> data="<?php echo $mlike?>" href="javascript:void(0);">♥</a>

                    <p class="love-p">有<span id="likenum"><?php echo $like['co']?></span>人喜欢</p>

                    <script>
                        //加入购物车
                        $('.buy-btn').click(function () {
                            var gid=$('#gid').val();
                            var mid=$('#mid').val();
                            if(!mid){
                                alert('请登录!谢谢');
                                return false;
                            }

                            //判断是否选择规格
                            if(did){
                                $.get("<?php $this->U('Index','flow')?>",{gid:gid,did:did,num:$('#number').val()},function (abc) {
                                    alert(abc.msg);

                                },'json');
                            }else{
                                alert('请选择规格!谢谢');
                            }
                        });

                        $('.love-btn').click(function () {
                            //判断用户名登录
                            var mid=$('#mid').val();
                            if(!mid){
                                alert('请登录!');
                                return false;
                            }
                            //判断有没有已经进入喜欢
                            var mlike=$(this).attr('data');
                            //发送ajax 加入喜欢
                            $.get("<?php $this->U('Index','likeadd')?>",{gid:$('#gid').val(),mlike:mlike},function (abc) {
                                alert(abc.msg);
                                if(abc.type==1){
                                    if(abc.msg=='加入成功'){
                                        $('.love-btn').css({'color':'red'});
                                        $('.love-btn').attr('data',1); //修改属性
                                        $('#likenum').html(Number($('#likenum').html())+1); //修改数量
                                    }else{
                                        $('.love-btn').css({'color':'#fff'});
                                        $('.love-btn').attr('data',0); //修改属性
                                        $('#likenum').html(Number($('#likenum').html())-1);//修改数量
                                    }
                                }
                            },'json');
                        })
                    </script>
                </div>
            </div>
        </div>
    </div>

    <div class="xlj-prodesc">
        <div class="goods-desc-menu">
            <ul class="hd clearfix">
                <li class="qh" data="1">
                    <a >产品详情</a>
                </li>
                <li class="qh" data="2">
                    <a >用户评价<span>(0)</span>
                    </a>
            </ul>
        </div>

        <div class="xlj-desc-box set-width">
            <!--商品详情-->
            <div class="xlj-box set-width1">
                <div class="xlj-good-desc">
                   <?php echo $goods['txt']?>
                </div>
            </div>

            <!--商品评论-->
            <div class="xlj-box set-width2" >

                <div class="bd">
                    <div class="goods-percent-list">
                        <div class="goods-percent">
                            <ul id="AllPercent" class="clearfix ">
                                <li>暂时还没有任何用户评论</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script>
            $(function () {
                //选择不同的规格实现改变价格
                // 最终价格 = (基本价格+规格加价)*数量

                var money=Number($('#money').val());
                var gmoney=0;
                did=0;
                //改变数量
                $('.sl').click(function () {
                   var type=$(this).attr('data');
                    num=Number($('#number').val());
                    kc=Number($('#kc').val());
                   if(type=='jia'){
                      num=num+1<=kc?num+1:kc; //判断库存
                   }else{
                       num=num-1>=1?num-1:1;
                   }
                   zmoney=((money+gmoney)*num).toFixed(2); //最终价格
                    $('#zmoney').html(zmoney); //修改价格
                    $('#number').val(num); //修改数量
                });
                //改变规格
                $('.guige').click(function () {
                    gmoney=Number($(this).attr('data')); //加价

                    did=$(this).attr('did'); //规格id

                    num=Number($('#number').val()); //数量
                    zmoney=((money+gmoney)*num).toFixed(2);//最终价格
                    $('#zmoney').html(zmoney); //修改价格

                    //修改样式
                    $('.guige').css({border: 'solid 1px #a0a0a0'});
                    $(this).css({border: 'solid 1px red'});
                });



                $('.set-width2').hide(); //隐藏评论
                $('.qh').click(function () {
                    var dat=$(this).attr('data');
                    $('.xlj-box').hide();

                    $('.set-width'+dat).show();
                })
            })
        </script>
    </div>
    <div class="blank"></div>
</div>

<?php $this->Hinc('footer')?>